package com.hhj.demo.springmvc.controller;

import com.hhj.demo.springmvc.annotations.KingAutowired;
import com.hhj.demo.springmvc.annotations.KingController;
import com.hhj.demo.springmvc.annotations.KingRequestMapping;
import com.hhj.demo.springmvc.annotations.KingRequestParam;
import com.hhj.demo.springmvc.service.HelloService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author KING
 * @date 2018/10/14 17:51
 */
@KingController
@KingRequestMapping("/hello")
public class HelloController {

    @KingAutowired("helloServiceImpl")
    private HelloService helloService;

    @KingRequestMapping("/say")
    public void say(HttpServletRequest request, HttpServletResponse response,
                         @KingRequestParam("name") String name,
                         @KingRequestParam("age") String age) {
        try {
            PrintWriter printWriter = response.getWriter();
            String msg = helloService.query(name, age);
            printWriter.write("hello-------" + msg);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
